<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>添加题库</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加题库</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="" style="width: 90%">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入名称" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">学科</label>
        <div class="layui-input-block">
            <select name="subject" lay-verify="subject" lay-search>
                <option value=""></option>
                <foreach name="ret_subject_list" item="vo" >
                    <option value="<{$vo.id}>"><{$vo.subject_name}></option>
                </foreach>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年级</label>
        <div class="layui-input-block">
            <select name="grade" lay-verify="grade" lay-search>
                <option value=""></option>
                <foreach name="grade" item="vo" >
                    <option value="<{$vo.id}>"><{$vo.name}></option>
                </foreach>

            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否启用</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" checked="" lay-skin="switch" title="状态" lay-text="开启|关闭" value="1">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="__PUBLIC__/BeginnerAdmin/plugins/layui/layui.js"></script>
<script src="__PUBLIC__/AmazeUI/assets/js/jquery-1.8.0.min.js"></script>
<script>
    function settime() {
        // window.location.href = 'Admin_Topic_NewTopicUI.html?examinationid=<{$examinationid}>';
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
    layui.use(['form', 'laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        //自定义验证规则
        form.verify({
            title: function(value) {
                if(value.length < 4) {
                    return '标题至少得4个字符啊';
                }
            }
        });

        //监听提交
        form.on('submit(demo1)', function(data) {
            $.post('Admin_Library_NewLibrary.html',data.field,function (ret) {
                if(ret.code == 200){
                    layer.msg('添加成功');
                    setTimeout('settime()', 1500);//延时执行，让人看得更清楚
                }else{
                    layer.alert(ret.msg);
                }
            },'json');
            return false;
        });
    });
</script>
</body>
</html>